﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace demo06__滚动窗口绘图
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //当工作区小于 300×250 像素时显示滚动条
            this.AutoScrollMinSize = new Size(300, 300);

            Form2 frm = new Form2();
            frm.Show();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = this.CreateGraphics();
            //g = e.Graphics;   可以直接使用

            Pen p = new Pen(Color.Red, 5);
            g.DrawEllipse(p, 120, 100, 150, 150);
            p.Dispose();
            g.Dispose();
        }
    }
}
